<?php

namespace pay\modules\frontend\models;

use Yii;

/**
 * This is the model class for table "pay_error_msg".
 *
 * @property int $id
 * @property string $url
 * @property string|null $code
 * @property string $msg 错误详情
 * @property string|null $data 数据
 * @property string|null $operation 操作用户
 * @property string $create_time 创建时间
 */
class ErrorMsg extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'pay_error_msg';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['url', 'msg', 'create_time'], 'required'],
            [['create_time'], 'safe'],
            [['url', 'msg', 'data'], 'string', 'max' => 255],
            [['code'], 'string', 'max' => 8],
            [['operation'], 'string', 'max' => 32],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'url' => 'Url',
            'code' => 'Code',
            'msg' => 'Msg',
            'data' => 'Data',
            'operation' => 'Operation',
            'create_time' => 'Create Time',
        ];
    }


    public function addInfo($data)
    {
        if ($this->load($data) and $this->validate()){
            if ($this->save(0)){
                return true;
            }
        }
        return false;
    }
}
